/*
 * @Author: zhangxin 411020991@qq.com
 * @Date: 2025-10-29 08:27:11
 * @LastEditors: zhangxin 411020991@qq.com
 * @LastEditTime: 2025-10-29 08:51:36
 * @FilePath: \子应用2\src\pages\ETrade\PowerGenerationPlan\components\GenerationPlan\componets\TimePeriod\index.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import React, { useState } from 'react';
import { Button, Modal } from 'antd';
import TimeSlotTable from '../TimeSlotTable';
import { imgString_2 } from '../../../../helper.js';
import styles from './index.less';
const index = ({ isTimeShow, setIsTimeShow, queryData, setRefreshCount, stations, dataCount }) => {
  const childRef = React.useRef(null);
  const handleCancel = () => {
    setIsTimeShow(false);
    setRefreshCount((prevCount) => prevCount + 1);
  };
  const _title = () => {
    return (
      <div className={styles.title}>
        <img src={imgString_2} />
        <div className={styles.iconText}>分时段录入</div>
      </div>
    );
  };

  // 定义一个方法来调用子组件的方法
  const handleOk = () => {
    if (childRef.current) {
      childRef.current.handleSubmit();
    }
  };
  return (
    <>
      <Modal
        className={styles.timeperiod_modal}
        title={_title()}
        closable={{ 'aria-label': 'Custom Close Button' }}
        visible={isTimeShow}
        centered={true}
        onOk={handleOk}
        onCancel={handleCancel}
        cancelText="取消"
        okText="确定"
      >
        <TimeSlotTable
          queryData={queryData}
          ref={childRef}
          handleCancel={handleCancel}
          stations={stations}
          dataCount={dataCount}
        />
      </Modal>
    </>
  );
};
export default index;
